<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>API-TEST</title>
</head>
<body>
	<br>
	<p>
		url: <input id="url" type="text" style="height:30px;width:400px;"/>
		ContentType: 
		<select id="ContentType">
		  <option value ="application/json;charset=utf-8">application/json;charset=utf-8</option>
		  <option value ="application/x-www-form-urlencoded">application/x-www-form-urlencoded</option>
		</select>
		type：
		<select id="type">
		  <option value ="post">post</option>
		  <option value ="get">get</option>
		</select>
	</p>
	<p>
		authorization:
		<select id="authorization">
		  <option value ="1">认证</option>
		  <option value ="2">不认证</option>
		</select>
		<button type="button" id="submit">提交</button>
	</p>
	<p>param:</p>
	<p>
		<textarea id="param" rows="15" cols="100"></textarea>
	</p>
	<p>response:</p>
	<p>
		<textarea id="response" rows="30" cols="100"></textarea>
	</p>
	<%-- <script type="text/javascript" src="${ctx}/static/jquery.js"></script> --%>
	<script src="http://libs.baidu.com/jquery/2.1.1/jquery.min.js"></script>
	<script>
		var token ="eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI4MjAzOTI1MTMiLCJpYXQiOjE1MjY2MzU4MTEsInN1YiI6IntcImlkXCI6ODIwMzkyNTEzLFwiY3JlYXRlZFRpbWVcIjpcIjIwMTgtMDUtMTQgMTU6MDM6NTBcIixcInVwZGF0ZWRUaW1lXCI6XCIyMDE4LTA1LTE0IDE1OjAzOjUwXCIsXCJjcmVhdGVkVXNlcklkXCI6MSxcInVwZGF0ZWRVc2VySWRcIjoxLFwiY3JlYXRlZFVzZXJOYW1lXCI6XCLns7vnu5_nrqHnkIblkZhcIixcInVwZGF0ZWRVc2VyTmFtZVwiOlwi57O757uf566h55CG5ZGYXCIsXCJzdGF0dXNcIjpudWxsLFwicmVtYXJrXCI6bnVsbCxcInN0cm9uZ2hvbGRJZFwiOjIsXCJpZGVudGl0eUNhcmRcIjpcIjUxMDEwMTExOTk5MDIwMjAxMFwiLFwiZHJpdmVyTmFtZVwiOlwiVzJcIixcInBob25lTnVtYmVyXCI6XCIxMjg1NTU1NTU1NVwiLFwic3BlY2lhbFBob25lTnVtYmVyXCI6XCIxMjg1NTU1NTU1NVwiLFwib3duZXJcIjpudWxsLFwiaXNVc2VcIjpcIllcIixcImNwbG9ncHRDZFwiOlwiUzAwMlwiLFwiY3BwbG50Q2RcIjpcIjFcIixcInN0cm9uZ2hvbGROYW1lXCI6XCJHWVNcIixcImltZWlcIjpudWxsLFwicGtcIjo4MjAzOTI1MTN9IiwiZXhwIjoxNTI3NDk5ODExfQ.UZuz5wdQ6Js7z5VaTr00zdH1T-sUwN2Q9KWP38j3cBA";
		$("#submit").on("click",function(){
			var base= "http://localhost:8080/loms-app-service";
			var url = base+"/"+$("#url").val();
			var ContentType = $("#ContentType").val();
			var type = $("#type").val();
			var param = $("#param").val();
			var authorization =  $("#authorization").val();
			
			var reqOpt ={
		        url: url,
		        type: type,
		        contentType : ContentType, 
		        dateType: 'json',
		        data: param,
		        success: function (json) {
		            $("#response").val(JSON.stringify(json,null,2));
		        }
		    }
			if(authorization == "1"){
				reqOpt.beforeSend =function (XMLHttpRequest) {
		        	XMLHttpRequest.setRequestHeader("Authorization", token);
		        	XMLHttpRequest.setRequestHeader("App-Type", "android");
		        	XMLHttpRequest.setRequestHeader("App-Version", "1.0.0");
		        };
			}
			$.ajax(reqOpt);
		});
	</script>
</body>
</html>